package com.example.cloudalibabaconfignacosclient.nacosconfig;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope//支持nacos动态刷新
public class ConfigClientController {
    @Value("${config.info}")
    private String configInfo;
    @Value("${config.other}")
    private String configOther;

    /**
     * 从配置中心获取配置值，并且可更新
     * @return
     */
    @GetMapping("/config/info")
    public String getConfigInfo() {
        return configInfo;
    }

    /**
     * 可以打印本地的值
     * @return
     */
    @GetMapping("/config/other")
    public String getConfigOther() {
        return configOther;
    }
}
